package com.qing.whiledemo;

public class WhileDemo {
    public static void main(String[] args) {
        WhileDemo.testWhile();
        WhileDemo.testDoWhile();
        //while是先判断再执行，dowhile是先执行后判断，所以dowhile最少会执行一次
    }

    public static void testWhile(){
        int i = 1;
        int sum = 0;
        while(i<=100){
            sum+=i;
            i++;
        }
        System.out.println(sum);
    }

    public static void testDoWhile(){
        int i = 0;
        int sum = 0;
        do {
            sum+=i;
            i++;
        }while (i<=100);
        System.out.println(sum);
    }

}
